package com.programmercarl.tree;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;

/**
 * https://leetcode.cn/problems/search-in-a-binary-search-tree/description/
 * 700.二叉搜索树中的搜索
 *
 * @author yulongtian
 * @create 2024-12-23 15:41
 */
public class Test17 {
    public static void main(String[] args) {
        new HashMap<>();
        int num = -2;
        System.out.println("取余：" + 7 % num);
        System.out.println("取模：" + Math.floorMod(7, num));
    }

    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode() {
        }

        TreeNode(int val) {
            this.val = val;
        }

        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }


    public TreeNode searchBST(TreeNode root, int val) {
        if (root == null) {
            return null;
        }
        if (root.val == val) {
            return root;
        }
        if (root.val < val) {
            return searchBST(root.right, val);
        }

        return searchBST(root.left, val);
    }

}
